/*
 * =====================================================================================
 *
 *       Filename:  io.h
 *
 *    Description: this is the early stage linux's io.h 
 *    i think this is useful so i copy it to here 
 *
 *        Version:  1.0
 *        Created:  2010年11月16日 12时10分14秒
 *       Revision:  none
 *       Compiler:  gcc
 *
 *         Author: lonelydragon 
 *        Company:  
 *     i do not know why there is so much wrong 
 *     i should be more carefully
 * =====================================================================================
 */

#define out(addr,port){ \
	__asm__("outb %%al,%%dx\n\t" : :"a"(addr),"d"(port));}


#define inp(port)({   	\
		unsigned char _v; \
		__asm__("inb %%dx,%%al":"=a"(_v):"d"(port));\
		_v;})

#define out_b(addr,port)({     \
	__asm__("outb %%al,%%dx\n\t"   \
			"jmp 1f\n\t"     \
			"1:jmp 1f\n\t"   \
			"1:\n\t "   ::"a"(addr),"d"(port) :    \
			); })


#define inp_b(port) ({   \
		unsigned char _v; \
		__asm__("inb %%dx,%%al\n\t" \
			"jmp 1f\n\t" \
			"1:jmp 1f\n\t" \
			"1:\n\t" \
			:"=a"(_v) :"d"(port)); _v;})
#define sti() ({ 	\
		__asm__("sti \t\n");   \
		})
#define cli() ({ 			\
		__asm__("cli \t\n"); 	\
		})
